import { defineStore } from "pinia";
import { FormDataState } from "./formDataState";
import { TableFields } from "@/api-services/models/codeGen";
import { CodeGenTableInfo } from "@/api-services/models/codeGen/CodeGenTableInfo";

export const useFormData = defineStore("formData", {
  state: (): FormDataState => ({
    drawingList: [],
    globalId: "", //字段id
    formConf: null, //
    tableFields: [], //数据表字段信息
    allTable: [] //所有数据表
  }),

  actions: {
    setDrawingList(data: Array<any>) {
      this.drawingList = data;
    },
    setGlobalId(id: string) {
      this.globalId = id;
    },
    setFormConf(data: any) {
      this.formConf = data;
    },
    setTableFields(data: Array<TableFields>) {
      this.tableFields = data;
    },
    setAllTable(data: Array<CodeGenTableInfo>) {
      this.allTable = data;
    }
  }
});
